#pragma once
#include "common.h"
#include "app/Activity.h"
#include "control/ZKListView.h"
#include "manager/ConfigManager.h"
#include "control/ZKTextView.h"
#include "utils/log.h"
#include "can/context.h"
#include "control/ZKPointer.h"
#include "system/Thread.h"

#include <string>


#ifndef DEBUG
#define DEBUG LOGE("--%d-- --%s-- Debug!!!\n", __LINE__, __FILE__);
#endif

typedef void (*CanCallBack)();
void AddCallback(CanCallBack updateSetCan);
void delCallback(CanCallBack updateSetCan);

extern int speedStart;
extern int speedEnd;
extern int tachStart;
extern int tachEnd;
extern UnitStatus unitStatus;
extern Vehicle_info1 info1;
extern V_Condition condition;            // ACC 挡位
extern V_Condition info0;

void setGear1(ZKTextView* gearPtr, ZKTextView* RankPtr, bool &isRegistered);
void setGear(ZKTextView* gearPtr,ZKTextView* RankPtr,bool &isRegistered);
void setSpeed(ZKTextView* pData, const uint16_t& shortValue);
void hideSpeedWin();
void showSpeedWin();
void hideTachBar();
void showTachBar();
//档级
#define PIRULEN "pirulen"
//粗体
#define ANAGO "anago-bold"
#define KICKER "KickerTrial-BlackUpright"
#define PIRBOLD "PirulenRg-Bold"
/*
 * @brife 控件设置字体
 * @param ctrlPtr 控件指针
 * @param font 字体名称（默认粗体）
 * */
static inline void setCtrlFont(ZKTextView* ctrlPtr, const std::string& font = ANAGO)
{
//	LOGD("--%d-- --%s-- 控件:%d 设置字体：%s\n", __LINE__, __FILE__, ctrlPtr->getID(), font.c_str());
	ctrlPtr->setFontFamily(font.c_str());
}


//线性仪表盘线程
class Refreshing: public Thread {
public:
	//连续线性刷新 速度 表盘，返回false表示到达终点
	bool refreshSpeed();
	//连续线性刷新 转速 表盘，返回false表示到达终点
	bool refreshTach();
	virtual bool readyToRun();
	virtual bool threadLoop();
	static Refreshing& getInstance();
	bool flagTach;
	bool flagSpd;
	ZKPointer* PointerRpm;
	ZKPointer* PointerSpeed;
};

#define REFRESHING		Refreshing::getInstance()

